
/*   RolGPS Project
 * 
 *   Copyright (C) 2009 Pablo Alejandro Costesich <rhfixer@gmail.com>
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 */
package org.rolgps.libedb.container;

import org.rolgps.libedb.standard.Result;
import java.sql.Blob;
import java.util.ArrayList;

/**
 *
 * @author xeph
 */
public class DataResult implements Result {

    ArrayList fields;

    public DataResult() {
    }

    public String getString(int index) {
        if (index < 0 && fields.size() > 0) {
            index = fields.size() - index;
        }
        return (String) fields.get(index);
    }

    public int getInt(int index) {
        if (index < 0 && fields.size() > 0) {
            index = fields.size() - index;
        }
        return (Integer) fields.get(index);
    }

    public Blob getBlob(int index) {
        if (index < 0 && fields.size() > 0) {
            index = fields.size() - index;
        }
        return (Blob) fields.get(index);
    }

    public double getDouble(int index) {
        if (index < 0 && fields.size() > 0) {
            index = fields.size() - index;
        }
        return (Double) fields.get(index);
    }

    public void addString(String str) {
        fields.add(str);
    }

    public void addInt(int integer) {
        fields.add(integer);
    }

    public void addBlob(Blob blob) {
        fields.add(blob);
    }

    public void addDouble(double doub) {
        fields.add(doub);
    }

    public int size() {
        return fields.size();
    }
}
